package com.crm.controller;

import com.crm.base.PageResult;
import com.crm.base.ResponseResult;
import com.crm.domain.dto.RoleDto;
import com.crm.domain.entity.Role;
import com.crm.domain.entity.User;
import com.crm.domain.vo.RoleVo;
import com.crm.mapper.RoleMapper;
import com.crm.service.RoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequiredArgsConstructor
@Api("角色管理")
public class RoleController {

    private final RoleService roleService;
    private final RoleMapper roleMapper;

    @GetMapping("/system/role/list")
    @ApiOperation("角色分页查询")
    public PageResult<Role> list(@RequestParam Integer pageNum, @RequestParam Integer pageSize) {
        return roleService.getPagedUsers(pageNum, pageSize);
    }

    @GetMapping("/system/user/")
    @ApiOperation("查询所有角色")
    public ResponseResult<List<RoleVo>> selectRole(RoleDto role){
       List<RoleVo> voList = roleService.select(role);
        return ResponseResult.success(voList);
    }

}
